<!DOCTYPE html>  
<html>  
  <head>  
    <title>throw</title>  
  </head>
  <body>  
    <script type="text/javascript">
      function checkAge(age) {
        if (age < 18) {
          throw new Error("Access denied - You must be at least 18 years old.");
        }
        else {
          document.write("Access granted - You are old enough!");
        }
      }

      checkAge(15); // Set age to 15 (which is below 18...)
    </script> 
  </body>  
</html>